import 'package:enterprise_v6_app/app/components/custom_app_bar.dart';
import 'package:enterprise_v6_app/app/components/custom_modele/custom_card.dart';
import 'package:enterprise_v6_app/app/core/core.dart';
import 'package:enterprise_v6_app/app/core/ext/widget_extension.dart';
import 'package:enterprise_v6_app/app/core/utils/interface.dart';
import 'package:enterprise_v6_app/app/data/entities/application/execute_entity.dart';

/// 安全措施确定情况
class SafetyMeasuresToDetermine extends StatelessWidget {
  const SafetyMeasuresToDetermine({super.key});

  ///	是否涉及 0：未涉及 1：涉及
  String _str(int? i) {
    switch (i) {
      case 0:
        return '未涉及';
      case 1:
        return '涉及';
      default:
        return '';
    }
  }

  @override
  Widget build(BuildContext context) {
    final List<ExecuteWorkSafetyMeasuresList> workSafetyMeasuresList = Get.arguments as List<ExecuteWorkSafetyMeasuresList>;
    return Scaffold(
      backgroundColor: AppColors.bg_color_grey,
      appBar: CustomAppBar(
        titleText: '安全措施确定情况',
      ),
      body: Container(
          padding: EdgeInsets.all(16.w),
          child: CustomCard(
            title: '安全措施',
            content: Expanded(
              child: ListView.separated(
                  itemCount: workSafetyMeasuresList.length,
                  itemBuilder: (context, index) {
                    final item = workSafetyMeasuresList[index];
                    final String title = item.safetyMeasures!
                        .replaceAll('-^', '')
                        .replaceAll('+^', '')
                        .replaceAll('-<', '')
                        .replaceAll('>-', '')
                        .replaceAll('-~', '')
                        .replaceAll('+~', '✔');
                    return Column(
                      children: [
                        AppGaps.vGap12,
                        Align(
                          alignment: Alignment.centerLeft,
                          child: Text(
                            '${index + 1}.$title',
                            textAlign: TextAlign.left,
                            style: TextStyle(
                              fontSize: 14.sp,
                              color: AppColors.font_color_black,
                            ),
                          ),
                        ),
                        AppGaps.vGap8,
                        Container(
                          padding: EdgeInsets.symmetric(horizontal: 12.w, vertical: 6.w),
                          decoration: const BoxDecoration(
                            color: Color(0x1A5C6DFF),
                          ),
                          child: Column(
                            children: [
                              Row(
                                children: [
                                  Text(
                                    '管控手段',
                                    style: TextStyle(
                                      fontSize: 14.sp,
                                      color: AppColors.font_color_black,
                                    ),
                                  ),
                                  AppGaps.hGap4,
                                  Expanded(
                                    child: Text(
                                      '${item.controlMeansName!.isEmpty ? '现场确认' : item.controlMeansName}',
                                      style: TextStyle(
                                        fontSize: 14.sp,
                                        color: AppColors.font_color_blue,
                                      ),
                                    ),
                                  ),
                                ],
                              ),
                              AppGaps.vGap4,
                              Row(
                                children: [
                                  Text(
                                    '是否涉及',
                                    style: TextStyle(
                                      fontSize: 14.sp,
                                      color: AppColors.font_color_black,
                                    ),
                                  ),
                                  AppGaps.hGap4,
                                  Text(
                                    _str(item.isInvolve),
                                    style: TextStyle(
                                      fontSize: 14.sp,
                                      color: AppColors.font_color_blue,
                                    ),
                                  ),
                                ],
                              ),
                              Row(
                                children: [
                                  Text(
                                    '确定人',
                                    style: TextStyle(
                                      fontSize: 14.sp,
                                      color: AppColors.font_color_black,
                                    ),
                                  ),
                                  AppGaps.hGap4,
                                  Expanded(
                                    child: Wrap(
                                      // spacing: 2.w, // 主轴(水平)方向间距
                                      runSpacing: 10.w, // 纵轴（垂直）方向间距
                                      direction: Axis.horizontal,
                                      children: item.userSign!.map<Widget>((item) {
                                        return Container(
                                          margin: EdgeInsets.only(top: 8.w, right: 8.w),
                                          width: 76.w,
                                          height: 36.w,
                                          decoration: BoxDecoration(
                                              borderRadius: BorderRadius.circular(4.w),
                                              color: Colors.white,
                                              border: Border.all(
                                                color: const Color(0xFFEFF2F6),
                                                width: 1,
                                              ),
                                              image: DecorationImage(
                                                image: NetworkImage(Interface.fileUrl + item),
                                              )),
                                        ).clickShowLarge(url: Interface.fileUrl + item);
                                      }).toList(),
                                    ),
                                  ),
                                ],
                              ),
                              Row(
                                children: [
                                  Text(
                                    '图片',
                                    style: TextStyle(
                                      fontSize: 14.sp,
                                      color: AppColors.font_color_black,
                                    ),
                                  ),
                                  AppGaps.hGap4,
                                  Expanded(
                                    child: Wrap(
                                      // spacing: 2.w, // 主轴(水平)方向间距
                                      runSpacing: 10.w, // 纵轴（垂直）方向间距
                                      direction: Axis.horizontal,
                                      children: item.images!.map<Widget>((item) {
                                        return Container(
                                          margin: EdgeInsets.only(top: 8.w, right: 8.w),
                                          width: 76.w,
                                          height: 36.w,
                                          decoration: BoxDecoration(
                                              borderRadius: BorderRadius.circular(4.w),
                                              color: Colors.white,
                                              border: Border.all(
                                                color: const Color(0xFFEFF2F6),
                                                width: 1,
                                              ),
                                              image: DecorationImage(
                                                image: NetworkImage(Interface.fileUrl + item),
                                              )),
                                        ).clickShowLarge(url: Interface.fileUrl + item);
                                      }).toList(),
                                    ),
                                  ),
                                ],
                              ),
                            ],
                          ),
                        ),
                        AppGaps.vGap8,
                      ],
                    );
                  },
                  separatorBuilder: (context, index) {
                    return Container(
                      height: 1.w,
                      color: const Color(0x33587DF5),
                    );
                  }),
            ),
          )),
    );
  }
}
